package com.app.cpcap.dao;

import java.util.List;

import org.hibernate.Session;

import com.app.cpcap.hibernate.HibernateConnectionFactory;

public class Dao<T> {
	private final Class classe;
	private final Session session;



	public Dao(Class classe, Session session) {
		super();
		this.classe = classe;
		this.session = session;
	}
	
	public List<T> list(){
		return session.createCriteria(classe).list();
	}
	public T get(Integer id){
		return (T)session.load(classe, id);
	}
	public void add(T o){
		session.save(o);
	}
	public void update(T o){
		session.merge(o);
	}
	public void delete(T o){
		session.delete(o);
	}
	protected Session getSession() {
		return session;
	}
}
